<template>
  <div>
    <my-header :showBack="true" :title="$t('lang.DynamicMR')"></my-header>
    <div>
      <div class="personal_info">
        <van-cell-group>
          <van-field v-model="userInfo.customerNumber"  :label="$t('lang.userNo')" :disabled="true"/>
          <van-field v-model="userInfo.levelName"  :label="$t('lang.CurrentLv')" :disabled="true"/>
          <van-field v-model="payWord"   :label="$t('lang.scccPword')"  type="password" :placeholder="$t('lang.enterSpword')" /> 
        </van-cell-group>
      </div>
      <div class="tips">
        <!-- <p>{{$t('lang.uwdaarpftcl2')}}</p> -->
        <p>注：动态配套复投将扣除100%注册分</p>
      </div>
      <div class="footer_btn">
        <van-button type="primary" size="large" @click="confirm">{{$t('lang.confirm')}}</van-button>
      </div>
    </div>
  </div>
</template>

<script>
import { Toast } from "vant";
import header from "@/components/header";

export default {
name: "modifyMsg",
  data() {
    return {
      userInfo:{},
      disabledInput:false,
      Leavetype:"",
      payWord:"",
    };
  },
  components: {
    "my-header": header
  },
  created() {
    let customerInfo = JSON.parse(localStorage.getItem('userInfo'));
    this.userInfo = {
      customerName:customerInfo.customerName||'',
      realName:customerInfo.realName||'',
      customerCard:customerInfo.idCard||'',
      customerPhone:customerInfo.customerPhone||'',
      customerAlipay:customerInfo.customerAlipay||'',
      bankName:customerInfo.bankName||'',
      bankCard:customerInfo.bankCard||'',
      // email:customerInfo.email||''
    }
    if(this.userInfo.idCard){
      this.disabledInput = true;
    }
  },
  mounted() {
    this.getUserInfo();
    console.log(this.Usertype)
  },
  methods: {
    getUserInfo() {
      //获取用户信息
      this.$ajax(this.$api.getMyInfo).then(res => {
        if (res.code == 0 && res.msg) {
          this.userInfo  = res.msg;
          localStorage.setItem("userInfo", JSON.stringify(res.msg));
          this.customerPhone=res.msg.customerPhone;
        }
      });
    },
    confirm() {
      if (this.payWord=='') {
        Toast({ message: this.$t('lang.enterSpword'), position: "bottom" });
        return;
      }
      if (!this.$validator.isPassword(this.payWord)) {
        Toast({ message: this.$t('lang.truepayPass'), position: "bottom" });
        return;
      }
      this.$ajax(this.$api.reinvest, {payPass:this.payWord}).then(res => {
        if (res.code === 0) {
          Toast({ message: this.$t('lang.CZsuccessful'), position: "bottom" });
          this.payWord="";
        }else{
          Toast({ message: res.msg, position: "bottom" });
        }
      });
    }
  }
};
</script>

<style scoped>
.personal_info{
  margin: 5px 0;
}
/* .personal_info .van-cell {
  border-bottom: 6px solid #f4f4f4;
} */
.personal_info .btn{
  width:80%;
  background: #26a2ff;
  margin-top:50px;
  margin-left: 10%;
  box-shadow: none;
  border-radius: 5px;
  color:#fff;
  font-size:16px;
}
.tips{color: #EB0700;padding: 12px;}
</style>